package com.yanmaohu.nikita.analyzer;

import com.yanmaohu.nikita.data.function.FunctionBody;
import com.yanmaohu.nikita.data.function.ParameterList;
import com.yanmaohu.nikita.data.function.statement.FunctionStatement;
import com.yanmaohu.nikita.data.function.statement.Statement;
import com.yanmaohu.nikita.scanner.SourceCode;

/**
 * @author Bright Lee
 */
public class StatementAnalyzer {

    private final SourceCode sourceCode;
    private final FunctionBody functionBody;

    public StatementAnalyzer(SourceCode sourceCode, FunctionBody functionBody) {
        this.sourceCode = sourceCode;
        this.functionBody = functionBody;
    }

    public void analyze() {
        if (functionBody == null || functionBody.isEmpty()) {
            return;
        }
        for (int i = 0; i < functionBody.size(); i++) {
            Statement statement = functionBody.get(i);
            if (statement instanceof FunctionStatement) {
                FunctionStatement functionStatement = (FunctionStatement) statement;
                ParameterList parameterList = functionStatement.getParameterList();
                new ParameterAnalyzer(sourceCode, parameterList).analyze();
                continue;
            }
            // TODO
        }
    }

}
